<template>
  <div class="test">
    <el-input v-model="inpOne" class="inp" placeholder="请输入数值"></el-input>
    +
    <el-input v-model="inpTwo" class="inp" placeholder="请输入数值"></el-input>
    = 测试输出数据是 [{{ numInp }}]
    <el-button type="primary" size="mini" @click="nums">点击测试数据</el-button>
  </div>
</template>

<script>
export default {
  data(){
    return {
      inpOne: '',
      inpTwo: '',
      numInp: ''
    }
  },
  methods: {
    nums(){
      // 需要对数据转换为数值计算
      this.numInp = Number(this.inpOne)+Number(this.inpTwo) 

      if(this.inpOne || this.inpTwo) {
        this.$message.success('测试成功')
        // this.inpOne = this.inpTwo = this.numInp = ''

      }else {
        this.$message.error('请从新输入数字')
        this.numInp = ''
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.test {
  .inp {
    width: 200px;
    height: auto;
  }
}
</style>